| Conditions | 7 |
| Total Lines | 30 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | var express = require('express'); |
||
| 29 | function register(res, body) { |
||
| 30 | const email = body.email; |
||
| 31 | const password = body.password; |
||
| 32 | |||
| 33 | if (!email || !password) { |
||
| 34 | return res.status(401).json({ |
||
| 35 | errors: { |
||
| 36 | status: 401, |
||
| 37 | source: "/register", |
||
| 38 | title: "Email or password missing", |
||
| 39 | detail: "Email or password missing in request" |
||
| 40 | } |
||
| 41 | }); |
||
| 42 | } |
||
| 43 | bcrypt.hash(password, 10, function(err, hash) { |
||
| 44 | |||
| 45 | db.run("INSERT INTO users (email, password) VALUES (?, ?)", |
||
| 46 | email, |
||
| 47 | hash, (err) => { |
||
| 48 | if (err) { |
||
| 49 | // console.log(err); |
||
| 50 | } |
||
| 51 | return res.status(201).json({ |
||
| 52 | data: { |
||
| 53 | message: "User successfully registered." |
||
| 54 | } |
||
| 55 | }); |
||
| 56 | }); |
||
| 57 | }); |
||
| 58 | } |
||
| 59 | |||
| 61 |